package com.xintonghua.hongyi.ui.user;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.xintonghua.base.ui.BaseActivity;
import com.xintonghua.base.ui.MySubscriber;
import com.xintonghua.base.utils.DividerItemDecoration;
import com.xintonghua.base.utils.MyUtils;
import com.xintonghua.base.utils.RefreshUtils;
import com.xintonghua.hongyi.R;
import com.xintonghua.hongyi.adapter.HomeAdapter;
import com.xintonghua.hongyi.adapter.ProductAdapter;
import com.xintonghua.hongyi.bean.ProductBean;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;

public class ProductActivity extends BaseActivity implements XRecyclerView.LoadingListener {

    @BindView(R.id.lv_product)
    XRecyclerView lvProduct;
    ProductAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product);
        ButterKnife.bind(this);
        onSimpleActionBar();
        setSimpleActionBar("产品");
        initUI();
    }

    @Override
    public void initUI() {
        super.initUI();
        RefreshUtils.initList(this, lvProduct);
        lvProduct.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL, MyUtils.dip2px(this, 4), ContextCompat.getColor(this, R.color.grey_bg)));
        adapter = new ProductAdapter(this, new ArrayList<ProductBean>());
        lvProduct.setAdapter(adapter);
        lvProduct.setLoadingListener(this);

    }

    @Override
    public void onRefresh() {
        RefreshUtils.onRefresh(adapter, lvProduct);

    }

    @Override
    public void onLoadMore() {
        lvProduct.loadMoreComplete();
    }
}
